package com.warrior.entity;

import javax.persistence.*;
import java.sql.Timestamp;

/**
 * Created by Shawn on 2017/3/15.
 */
@Entity
@Table(name = "match_details", schema = "warrior")
public class MatchDetailsEntity {
    private String id;//记录具体场次id,用MD-32位uuid表示
    private String homeTeamId;//记录主队id
    private String visitingTeamId;//记录客队id
    private Integer matchResult;//记录该场赛事结果,0表示平局,1表示主队胜,2表示主队负
    private Integer homeScore;//记录主队得分
    private Integer visitingScore;//记录客队得分
    private Timestamp matchTime;//记录比赛时间字段
    private Timestamp createdAt;//记录该条记录的创建时间
    private Timestamp updateAt;//记录该条记录的更新时间
    private String createdBy;//记录该条记录的创建者
    private String updateBy;//记录该条记录由何人更新
    private ActivityEntity activityByActiveId; //记录该场具体比赛的活动id

    @Id
    @Column(name = "id")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Basic
    @Column(name = "home_team_id")
    public String getHomeTeamId() {
        return homeTeamId;
    }

    public void setHomeTeamId(String homeTeamId) {
        this.homeTeamId = homeTeamId;
    }

    @Basic
    @Column(name = "visiting_team_id")
    public String getVisitingTeamId() {
        return visitingTeamId;
    }

    public void setVisitingTeamId(String visitingTeamId) {
        this.visitingTeamId = visitingTeamId;
    }

    @Basic
    @Column(name = "match_result")
    public Integer getMatchResult() {
        return matchResult;
    }

    public void setMatchResult(Integer matchResult) {
        this.matchResult = matchResult;
    }

    @Basic
    @Column(name = "home_score")
    public Integer getHomeScore() {
        return homeScore;
    }

    public void setHomeScore(Integer homeScore) {
        this.homeScore = homeScore;
    }

    @Basic
    @Column(name = "visiting_score")
    public Integer getVisitingScore() {
        return visitingScore;
    }

    public void setVisitingScore(Integer visitingScore) {
        this.visitingScore = visitingScore;
    }

    @Basic
    @Column(name = "match_time")
    public Timestamp getMatchTime() {
        return matchTime;
    }

    public void setMatchTime(Timestamp matchTime) {
        this.matchTime = matchTime;
    }

    @Basic
    @Column(name = "created_at")
    public Timestamp getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Timestamp createdAt) {
        this.createdAt = createdAt;
    }

    @Basic
    @Column(name = "update_at")
    public Timestamp getUpdateAt() {
        return updateAt;
    }

    public void setUpdateAt(Timestamp updateAt) {
        this.updateAt = updateAt;
    }

    @Basic
    @Column(name = "created_by")
    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    @Basic
    @Column(name = "update_by")
    public String getUpdateBy() {
        return updateBy;
    }

    public void setUpdateBy(String updateBy) {
        this.updateBy = updateBy;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        MatchDetailsEntity that = (MatchDetailsEntity) o;

        if (id != null ? !id.equals(that.id) : that.id != null) return false;
        if (homeTeamId != null ? !homeTeamId.equals(that.homeTeamId) : that.homeTeamId != null) return false;
        if (visitingTeamId != null ? !visitingTeamId.equals(that.visitingTeamId) : that.visitingTeamId != null)
            return false;
        if (matchResult != null ? !matchResult.equals(that.matchResult) : that.matchResult != null) return false;
        if (homeScore != null ? !homeScore.equals(that.homeScore) : that.homeScore != null) return false;
        if (visitingScore != null ? !visitingScore.equals(that.visitingScore) : that.visitingScore != null)
            return false;
        if (matchTime != null ? !matchTime.equals(that.matchTime) : that.matchTime != null) return false;
        if (createdAt != null ? !createdAt.equals(that.createdAt) : that.createdAt != null) return false;
        if (updateAt != null ? !updateAt.equals(that.updateAt) : that.updateAt != null) return false;
        if (createdBy != null ? !createdBy.equals(that.createdBy) : that.createdBy != null) return false;
        if (updateBy != null ? !updateBy.equals(that.updateBy) : that.updateBy != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (homeTeamId != null ? homeTeamId.hashCode() : 0);
        result = 31 * result + (visitingTeamId != null ? visitingTeamId.hashCode() : 0);
        result = 31 * result + (matchResult != null ? matchResult.hashCode() : 0);
        result = 31 * result + (homeScore != null ? homeScore.hashCode() : 0);
        result = 31 * result + (visitingScore != null ? visitingScore.hashCode() : 0);
        result = 31 * result + (matchTime != null ? matchTime.hashCode() : 0);
        result = 31 * result + (createdAt != null ? createdAt.hashCode() : 0);
        result = 31 * result + (updateAt != null ? updateAt.hashCode() : 0);
        result = 31 * result + (createdBy != null ? createdBy.hashCode() : 0);
        result = 31 * result + (updateBy != null ? updateBy.hashCode() : 0);
        return result;
    }

    @ManyToOne
    @JoinColumn(name = "active_id", referencedColumnName = "id", nullable = false)
    public ActivityEntity getActivityByActiveId() {
        return activityByActiveId;
    }

    public void setActivityByActiveId(ActivityEntity activityByActiveId) {
        this.activityByActiveId = activityByActiveId;
    }
}
